package com.practice;

import lombok.extern.slf4j.Slf4j;

/**
 * @author 罗俊华
 * @date 2021/9/3 - 2:36 下午
 */
@Slf4j
public class TicketWindow {

    private int count;

    public  TicketWindow(int count) {
        this.count = count;
    }

    public synchronized int getCount() {
        return count;
    }

    public synchronized int sell(int amount) {
        if (this.count >= amount) {
            this.count -= amount;
            return amount;
        } else {
            return 0;
        }
    }
}
